import numpy as np

def newton_interpolate(x_points, y_points, x_experiment):
    n = len(x_points)
    # 初始化差商表
    coefficients = np.zeros([n, n])
    if len(y_points) != n:
        raise ValueError('x_points and y_points must have the same length')
    # 第 0 列初始化为 y_points
    coefficients[:,0] = y_points
    
    # 计算 i 阶差商
    for j in range(1, n):
        for i in range(n - j):
            coefficients[i][j] = (coefficients[i + 1][j - 1] - coefficients[i][j - 1]) / (x_points[i + j] - x_points[i])

    def P(x):
        result = coefficients[0,0]
        term = 1
        for i in range(1, n):
            # 第 i 阶差商
            term *= (x - x_points[i - 1])
            result += coefficients[0, i] * term
        return result
    
    return [P(x) for x in x_experiment]
